Match string started with a specific number¶
re.compile(r”^5”)
Write a python program where a string will start with a specific number.
import re
def match_num(S):
text = re.compile(r"^5")
if text.match(S):
return True
else:
return False
# test
print(match_num('5-2345861')) # True
print(match_num('6-2345861')) # False